<ui:composition template="/template/template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pm="http://primefaces.org/mobile">

	<ui:define name="centerbody">
		<p:panelGrid columns="3">
			<p:outputLabel value="Campo"></p:outputLabel>
			<p:outputLabel value="Valor"></p:outputLabel>
			<p:outputLabel value="Alerta"></p:outputLabel>
			<p:outputLabel value=" Nome: "></p:outputLabel>
			<p:inputText id="nome" label="Nome" value="#{customersBean.customer.nome}"></p:inputText>
			<p:message id="message_nome" for="nome" style="color: red" />
			<p:outputLabel value=" CNPJ: "></p:outputLabel>
			<p:inputText id="cnpj" label="CNPJ" value="#{customersBean.customer.cnpj}">
			<f:ajax event="keyup" execute="cnpj" render="message" ></f:ajax>
			<f:validateLength minimum="5" maximum="10"></f:validateLength>
			</p:inputText>
			<p:message id="message" for="cnpj" style="color: red" />
			<p:outputLabel value=" Status: "></p:outputLabel>
			<p:selectOneMenu value="#{customersBean.customer.status}">
				<f:selectItem itemValue="Ativo" itemLabel="Cliente ativo"></f:selectItem>
				<f:selectItem itemValue="Inativo" itemLabel="Cliente inativo"></f:selectItem>
			</p:selectOneMenu>
			<p:graphicImage library="customer" name="house.jpg"></p:graphicImage>
			<p:commandButton update="customerslist" value="+"
				action="#{customersBean.addCustomer}"></p:commandButton>
		</p:panelGrid>
		<p:dataTable id="customerslist" resizableColumns="true"
			style="padding-top:10px" var="customer"
			value="#{customersBean.customers}"
			rendered="#{not empty customersBean.customers}">
			<p:column headerText="Cliente">
				<h:outputText value="#{customer.nome}" />
			</p:column>
			<p:column headerText="CNPJ">
				<h:outputText value="#{customer.cnpj}" />
			</p:column>
			<p:column headerText="Situação">
				<h:outputText value="#{customer.status}" />
			</p:column>
			<p:column headerText="Remover">
				<p:commandButton value="-" update="customerslist"
					action="#{customersBean.removeCustomer(customer)}"></p:commandButton>
			</p:column>
		</p:dataTable>
	</ui:define>
</ui:composition>


